#!/usr/bin/perl
#groupmember_setting.cgi

require './mdmjobs-lib.pl';
&ReadParse();

&header($text{'groupmember_detail'}, "", "index", 0, 1,undef,undef);
print "<form action=mdm_groupmember.cgi method=post onsubmit='return checkselect(\"$text{'err_nomember'}\",\"$text{'err_noname'}\");'>\n";
print "<table class=mode1 border=0 cellspacing=0 cellpadding=0>\n";
print "<tr><td>\n";
local $grpinfo=&foreign_call("mdmgroups","get_groupinfo");
local %grpinfo=%$grpinfo;
local @group = split (/,/,$grpinfo{'[group]'});
&select_members(\@group);	
print "</td></tr>\n";

print "<tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=2>\n";
print "<hr align=left width=550>\n";
print "<tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=2>\n";
print "<h4>$text{'index_setgroup'}</h4>\n";
print "$text{'index_setgroupmemmsg'}<p>\n";
print "</table></td></tr>\n";
print "<tr><td><table class=mode1 border=0 cellspacing=0 cellpadding=4>\n";
print "<tr><td><b>$text{'groupname'}</b></td><td><input value='' name=groupname></td></tr>\n";
print "<tr><td><b>$text{'membernames'}</b></td>\n";
print "<td><table class=mode1 border=0 cellspacing=0 cellpadding=2>\n";
print "<tr><td><input value='' name=membersname1></td>\n";
print "<td><input value='' name=membersname2></td>\n";
print "<td><input value='' name=membersname3></td>\n";
print "<td><input value='' name=membersname4></td></tr>\n";
print "</table></td></tr>\n";
print "</table></td></tr>\n";
print "<tr><table class=mode1 border=0 cellspacing=4 cellpadding=4>\n";
print "<tr><td><input type=submit class=button value=\"$text{'index_addmem'}\" onclick=\"return checkclick('add');\"></td>\n";
print "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit class=button value=\"$text{'index_delmem'}\" onclick=\"return checkclick('del');\"></td></tr>\n";
print "<input type=hidden name=opera value='add'>\n";
print "</table></td></tr>\n";

print "</table></form>\n";
print <<EOF;
<script>
function checkselect(alertmessg1,alertmessg2)
{
	if(document.forms[0].memberlist.options.length == 0){
		alert(alertmessg1);
		return false;
	}
	
	if(!confirm("$text{'msg_confirm'}")){
                return false;
        }
	
	if(document.forms[0].listinput.value == ""){
		if(document.forms[0].memberlist.options.length > 0){
			document.forms[0].listinput.value = document.forms[0].memberlist.options[0].text;
		}else{
			document.forms[0].listinput.value = "";
		}	

		for(i = 1; i < document.forms[0].memberlist.options.length; i++){
			document.forms[0].listinput.value += "," + document.forms[0].memberlist.options[i].text;
		}
	}
}

function checkclick(opertion)
{
	if (opertion == "del"){
		document.forms[0].opera.value = "del";
	}else{
		document.forms[0].opera.value = "add";
	}
}

</script>
EOF

&footer("index.cgi", $text{'index_title'});
1;
